'use strict';

/**
 * @ngdoc directive
 * @name jgappApp.directive:maskerDirective
 * @description
 * # maskerDirective
 */
angular.module('jgappApp')
    .directive('maskerDirective', function($rootScope) {
        return {
            scope: {},
            template: '<div class="masker" ng-show="showMasker" ng-click="closeMasker()"></div>',
            restrict: 'AE',
            replace: true,
            link: function postLink(scope, element, attrs) {
                // element.text('this is the maskerDirective directive');
                // scope.showMasker = true
                element.bind("touchmove", function(event) {
                    event.stopPropagation();
                    event.preventDefault();
                });
                scope.closeMasker = function() {
                    $rootScope.$broadcast('closemasker');
                };
                $rootScope.$on('showmasker', function() {
                    scope.showMasker = true
                });
                $rootScope.$on('closemasker', function() {
                    scope.showMasker = false
                    $rootScope.$emit('maskerClosed');
                });
                
            }
        };
    });
